package doublepointer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Author: sfy
 * @Date: 2024/1/29 22:51
 * @Description: 数组元素目标和
 */
public class Main2 {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        String[] split1 = br.readLine().split(" ");
        int n = Integer.parseInt(split1[0]);
        int m = Integer.parseInt(split1[1]);
        int target = Integer.parseInt(split1[2]);
        int[] arr1 = new int[n];
        int[] arr2 = new int[m];
        String[] split2 = br.readLine().split(" ");
        String[] split3 = br.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            arr1[i] = Integer.parseInt(split2[i]);
        }
        for (int i = 0; i < m; i++) {
            arr2[i] = Integer.parseInt(split3[i]);
        }
        //两个指针一个指向第一个数组头部，一个指向第二个数组尾部
        for (int i = 0, j = m - 1; i < n; i++) {
            while (j >= 0 && arr1[i] + arr2[j] > target) {
                j--;
            }
            if (arr1[i] + arr2[j] == target) {
                System.out.println(i + " " + j);
                break;
            }
        }
    }
}
